package com.yuezhi.utils;

import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * @program: yuezhi-parent
 * @description:
 * @author: Mr.Liao
 * @create: 2020-12-16 13:51
 **/
@Data
public class R {
    private Integer code;
    private String  msg;
    private Map<String,Object> data =new HashMap<>();

    private R(Integer code, String msg){
        this.code=code;
        this.msg=msg;
    }

    public static R success(){
        return new R(200,"成功");
    }

    public static R error(){
        return new R(201,"失败!");
    }

    
    public R code(Integer code){
        this.setCode(code);
        return this;
    }

    public R msg(String msg){
        this.setMsg(msg);
        return this;
    }
    public R data(String key,Object value){
        this.data.put(key, value);
        return this;
    }

    public R data(Map<String ,Object> data){
        this.setData(data);
        return this;
    }
}
